<?php

include(dirname(__FILE__).'/../../bootstrap/functional.php');
/* Was generated:
$browser = new sfTestFunctional(new sfBrowser());

$browser->
  get('/Document/index')->

  with('request')->begin()->
    isParameter('module', 'Document')->
    isParameter('action', 'index')->
  end()->

  with('response')->begin()->
    isStatusCode(200)->
    checkElement('body', '!/This is a temporary page/')->
  end()
;
*/

sfConfig::set('FUNC_ADMIN_USER', 'Admin@mail.ru');
sfConfig::set('FUNC_ADMIN_PASS', '1111');

$browser = new SimpleDocFlowTestFunctional(new sfBrowser());
$browser->
	info("go to some right page without login: make sure we did not get access")->
	get('/document/new')->
	with('response')->
	begin()->
		isStatusCode(401)->
	end()->
	
	info("due to our used HTTP auth, the request is redirected to our secure module")->
	isForwardedTo('sfGuardAuth', 'signin')->
	
	
	info("do log in")->
	with('form')->
	begin()->
		click('sign in', array(
			'signin' => array(
				'username' => sfConfig::get('FUNC_ADMIN_USER'),
				'password' => sfConfig::get('FUNC_ADMIN_PASS'))))->
	end()->
	
	
	info("try again to access the appointment page: make sure we have access now")->
	get('/document/new')->	
	with('response')->
	begin()->
		isStatusCode(200)->
		checkElement('body', '!/This is a temporary page/')->
		//checkElement('input', '/Submit/')->
	end()
;

$browser->loadData();

$browser->
	setAuth( sfConfig::get('FUNC_ADMIN_USER'), sfConfig::get('FUNC_ADMIN_PASS') )->
	get('/document/new')->
	with('request')->begin()->
		isParameter('module', 'document')->
		isParameter('action', 'new')->
	end()
;

$browser->
	setAuth( sfConfig::get('FUNC_ADMIN_USER'), sfConfig::get('FUNC_ADMIN_PASS') )->
	get('/document/info/1/document-1')->
	with('request')->begin()->
		isParameter('module', 'Document')->
		isParameter('action', 'info')->
		isParameter('id', '1')->
		isParameter('name_slug', 'document-1')->
	end()
;

/* Do not see Upload in /file/info/id/1 page.
$browser->
	setAuth( sfConfig::get('FUNC_ADMIN_USER'), sfConfig::get('FUNC_ADMIN_PASS') )->
	get('/document/info/id/1')->
	click('Upload');
	with('request')->begin()->
		isParameter('module', 'Document')->
		isParameter('action', 'info')->
		isParameter('id', '1')->
	end()
;
*/
